package com.kzd.gtgame.entity

import com.blankj.utilcode.util.GsonUtils
import com.chad.library.adapter.base.entity.MultiItemEntity

data class GameDetailsItem<T>(
    val type: Int,
    val title: String? = null,
    val text: String? = null,
    val list: MutableList<T> = mutableListOf()
) : MultiItemEntity {
    override val itemType: Int
        get() = type

    fun <T> getConversionList(type: Class<T>): MutableList<T> {
        if (list.isNullOrEmpty()) {
            return mutableListOf()
        }
        val list2: MutableList<T> = mutableListOf()
        for (elem in list) {
            list2.add(GsonUtils.fromJson(GsonUtils.toJson(elem), type))
        }
        return list2
    }
}

data class GamDetailsGroup(
    val type: Int,
    val title: String? = null,
    val any: Any? = null
) : MultiItemEntity {
    override val itemType: Int
        get() = type

    fun <T> getConversionList(type: Class<T>): T {
        return GsonUtils.fromJson(GsonUtils.toJson(any), type)
    }

    data class Text(
        val text: String
    )

    data class Graphic(
        val text: String,
        val list: MutableList<String> = mutableListOf()
    )
}